package cn.virens.cmpt.rabbit.packet;

import java.io.Serializable;
import java.nio.charset.Charset;

import com.alibaba.fastjson.JSON;

import cn.hutool.core.util.StrUtil;

public abstract class RabbitPacket implements Serializable {
	private static final long serialVersionUID = 9204932968129541278L;

	private String mac;// 设备编号(所有设备)

	public String getMac() {
		return mac;
	}

	public void setMac(String mac) {
		this.mac = mac;
	}

	public abstract String cmd();

	/** 指令包序列化 */
	public byte[] serialize(Charset charset) {
		return StrUtil.bytes(toString(), charset);
	}

	@Override
	public String toString() {
		return JSON.toJSONString(this);
	}
}
